﻿using System;
using System.Collections.Generic;
using NUnit;
using NUnit.Framework;
using Rhino.Mocks;
using System.Diagnostics;

namespace mForum.Infrastructure.NHibernate.Tests
{
    using mForum.Domain.DomainObject;
    using mForum.Core.Infrastructure;
    using mForum.Core.Infrastructure.Configuration;
    using mForum.Domain.Repository;
    using mForum.Infrastructure.NHibernate;
    using mForum.Infrastructure.NHibernate.Repository;

    public class BaseDatabaseTest
    {
        protected readonly string _connectionString = "Data Source=AIKER;Initial Catalog=mForum;Integrated Security=True";
        protected readonly string _providerName = "System.Data.SqlClient";

        protected IConfigurationWrapper _configurationWrapper;
        protected IDatabaseFactory _dbFactory;
        protected IUnitOfWork _uow;

        //repositories
        protected IUserRepository _userRepository;

        [SetUp]
        public void Initialize()
        {
            _configurationWrapper = MockRepository.GenerateMock<IConfigurationWrapper>();
            _configurationWrapper.Stub(x => x.ConnectionString).Return(_connectionString);
            _configurationWrapper.Stub(x => x.ProviderName).Return(_providerName);

            _dbFactory = new DatabaseFactory(_configurationWrapper);
            _uow = new UnitOfWork(_dbFactory);

            _userRepository = new UserRepository(_dbFactory);
        }
    }
}
